// Output of graphic text
//
// PLAN: 1. text can be selected into canvas, so don't need to pass on every time? -OB
//	     2. can clone a text by different attributes?

#ifndef _TEXT_H_
#define _TEXT_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "Font.h"

/////////////////////////////////////////////////////////////////////////////
// Text class

/* Code pages */
#define TEXT_CP_DEFAULT		0
#define TEXT_CP_ISO_8859_1	1	// this is for English/Western Europe and only ASCII font needed
#define TEXT_CP_UNICODE		2	// not supported yet!
#define TEXT_CP_BIG5		3	// the is for Trad. Chinese and was mixed ASCII and DBCS fonts
#define TEXT_CP_GB2312		4	// the is for Simple Chinese and was mixed ASCII and DBCS fonts

// Effects for g_SetTextEffect/g_SetTextFormat
#define TEXT_NORMAL         FONT_FX_NORMAL	// reset to default, should not combine with any others
#define TEXT_OPAQUE		    FONT_FX_OPAQUE
#define	TEXT_BOLD           FONT_FX_BOLD
#define TEXT_SHADOW         FONT_FX_SHADOW	// not yet!!!
#define TEXT_OUTLINE        FONT_FX_OUTLINE	
#define TEXT_ZOOM_2			FONT_FX_ZOOM_X2	// not yet!!!

// Aligns for g_Puts/g_Printf
#define TEXT_ALIGN_CENTER	0	// default is center
#define TEXT_ALIGN_LEFT		1
#define TEXT_ALIGN_RIGHT	2
#define TEXT_ALIGN_TOP		4
#define TEXT_ALIGN_BOTTOM	8

#define ARROW_WIDTH	10

typedef struct _Text
{
/* ready only */
    TFont	ASCII;		// Single Bytes Character Set (ASCII)
    TFont	DBCS;       // Double Bytes Character Set
   
/* ready/write */
    int		HSpace;     // horizontal space
    int		VSpace;     // vertical space 
    
/* in test */

}	TText;   
   
/* set text code page */
//void g_SetTextCodePage(int coding);

/* Create a text object */
int  g_CreateText(TText *text, const char *fontname, int cache);

/* Destroy a font object */
void g_DestroyText(TText *text);

/* Set new color scheme */
void g_SetTextColor(TText *text, int fgColor, int bgColor);

/* Get color scheme */
void g_GetTextColor(const TText *text, int *fgColor, int *bgColor);

/* Set Text effect */
void g_SetTextEffect(TText *text, int effects);

/* Set color of outline effect */
void g_SetTextGlowColor(TText *text, int glColor);

/* Set text format
   = g_SetTextEffect+g_SetTextColor+g_SetTextGlowColor */
void g_SetTextFormat(TText *text, int effects, int fgColor, int bgColor, int glColor);

/* Compute the string width in pixels */
int  g_GetTextWidth(const TText *text, const char *str);

/* Compute the string height in pixels */
int  g_GetTextHeight(const TText *text);

/* Print a format string on canvas in x,y */
void g_PrintfXY(const TCanvas *canvas, const TText *text, int x, int y, const char *format,...);

/* Output a string on canvas in x,y */
void g_PutsXY(const TCanvas *canvas, const TText *text, int x, int y, const char *str);

/* Output a character on canvas in x,y */
int  g_PutcXY(const TCanvas *canvas, const TText *text, int x, int y, int ch);

/* Print a format string on canvas inside a rectangle */
void g_Printf(const TCanvas *canvas, const TText *text, TRect rect, int align, const char *format,...);

/* Output a string on canvas inside a rectangle */
void g_Puts(const TCanvas *canvas, const TText *text, TRect rect, int align, const char *str);

char *g_PutsXYLimit(const TCanvas *canvas, const TText *text, int x, int y, int maxWidth, int postfix, const char *str);

extern int (*g_WPutcXY)(const TCanvas *canvas, const TText *text, int x, int y, int highByte, int lowByte);


void g_PutWordXY_GB2312(const TCanvas * canvas,const TText * text,int x,int y,int highByte,int lowByte);


// Thai
BOOL g_GetIsThaiInputRule(char Lch, char Fch);

char *g_GetThaiNextChr(const char *str);

#ifdef __cplusplus
}
#endif

#endif  // _TEXT_H_
